﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using Maticsoft.DBUtility;//Please add references
namespace lcmyjobs.DAL
{
    /// <summary>
    /// 数据访问类:user_basic
    /// </summary>
    public partial class user_basic
    {
        public user_basic()
        { }
        #region  Method
        public bool isadvorreward(int id)
        {
            string sql = "select count(*) from Vresume where [uid]=@uid and (advstatus=1 or rewardstatus=1)";
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)};
            parameters[0].Value = id;
            object b=DbHelperSQL.GetSingle(sql, parameters);
            if (b != null && b.ToString() == "1")
            {
                return true;
            }
            else
                return false;
        }
        public int FindIDByRBH(string rbh)
        {
            int rowa = 0;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@rbh", SqlDbType.Char,8)
                   
};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = rbh;
            DbHelperSQL.RunProcedure("[dbo].[FindIDByRBH]", parameters, out rowa);
            return int.Parse(parameters[0].Value.ToString());

        }
        public int FindIDByABH(string rbh)
        {
            int rowa = 0;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@abh", SqlDbType.Char,6)
                   
};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = rbh;
            DbHelperSQL.RunProcedure("[dbo].[FindIDByABH]", parameters, out rowa);
            return int.Parse(parameters[0].Value.ToString());

        }
        public DataSet FindIDByEmail(string email)
        {
            return DbHelperSQL.Query("select uid,name,resetpwdtime from user_basic where email= '" + email + "'");
        }
        public int setResetPWDTime(string uid, string resetpwdtime)
        {
            return DbHelperSQL.ExecuteSql("update user_basic set resetpwdtime=" + resetpwdtime + " from user_basic where uid=" + uid);
        }
        public DataSet getResetPWDTime(string uid)
        {
            return DbHelperSQL.Query("select resetpwdtime,pwd from user_basic where uid=" + uid);
        }
        public int adduserhunter(int uid, int rid, out int rowa)
        {

            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@enterprise_aid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = uid;
            parameters[1].Value = rid;
            return DbHelperSQL.RunProcedure("[dbo].[P_Addaskhunter]", parameters, out rowa);
            //return rowsAffected;

        }
        public int adduseremp(int uid, int rid, out int rowa)
        {

            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@enterprise_rid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = uid;
            parameters[1].Value = rid;
            return DbHelperSQL.RunProcedure("[dbo].[P_Adduseremp]", parameters, out rowa);
            //return rowsAffected;

        }
        public int addusercollect(int uid, int rid, out int rowa)
        {

            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@enterprise_rid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = uid;
            parameters[1].Value = rid;
            return DbHelperSQL.RunProcedure("[dbo].[P_Addusercollect]", parameters, out rowa);
            //return rowsAffected;

        }
        public int updateusertime(int uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_usertime]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deletebrowse(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_deleteuserbrowse]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deleteinterview(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_deleteuserinterview]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deleteemps(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_deleteuseremp]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deleteaskhunters(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@aid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_useraskhunterdeletes]", parameters, out rowsAffected);
            return rowsAffected;
        }
        public int deletecollects(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_deleteusercollect]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UserLogin(string name, string pwd, out string mname,out string datetime)
        {
            int rowsAffected, id = 0;
            SqlParameter[] parameters = {
					
					new SqlParameter("@name", SqlDbType.VarChar,15),
					new SqlParameter("@pwd", SqlDbType.VarChar,20),
                    new SqlParameter("@truename",SqlDbType.NVarChar,20),
                    new SqlParameter("@datetime",SqlDbType.DateTime)};
            parameters[0].Value = name;
            parameters[1].Value = pwd;
            parameters[2].Direction = ParameterDirection.Output;
            parameters[3].Direction = ParameterDirection.Output;
            id = DbHelperSQL.RunProcedure("[dbo].[P_UserLogin]", parameters, out rowsAffected);
            mname = parameters[2].Value.ToString();
            datetime = parameters[3].Value.ToString();
            return id;

        }
        public int UpdateRewardTime(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
};
            parameters[0].Value = uid;

            DbHelperSQL.RunProcedure("[dbo].[P_userrewardtime]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateAskHunterStatus(string aid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@aid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = aid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_userAHstatus]", parameters, out rowsAffected);
            return rowsAffected;
        }
        public int UpdateRewardOKStatus(string uid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_userrewardOK]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateRewardStatus(string uid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_userrewards]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateAdvTime(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
};
            parameters[0].Value = uid;

            DbHelperSQL.RunProcedure("[dbo].[P_useradvtime]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateAdvOKStatus(string uid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_useradvOK]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateAdvStatus(string uid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_useradvs]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdateStatus(string uid, int st)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200),
                    new SqlParameter("@sta",SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            parameters[1].Value = st;
            DbHelperSQL.RunProcedure("[dbo].[P_userchecks]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deleteusers(string uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
                   
};
            parameters[0].Value = uid;
            DbHelperSQL.RunProcedure("[dbo].[P_userdeletes]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public DataSet GetUserJobs(int uid)
        {
            return DbHelperSQL.Query("select jobs_id,job_name from Vuserjob where uid=" + uid);
        }

        public DataSet GetAdminMain(int atid)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4)
};
            parameters[0].Value = atid;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_getAdminData]", parameters, "ds");
            return ds;
        }
        public DataSet GetUserMain(int uid)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_UserMain]", parameters, "ds");
            return ds;
        }
        public DataSet GetUserEmails(string uid)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.VarChar,200)
};
            parameters[0].Value = uid;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_GetUserEmails]", parameters, "ds");
            return ds;
        }
        public DataSet PageUserAskHunter(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageAskHunter]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserBrowse(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserBrowse]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserSearch(SqlParameter[] parameters)
        {

            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_searchUser]", parameters, "ds");
            return ds;
        }
        public DataSet PageUserNew(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserNew]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserInterview(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserInterview]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserEmp(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserEmp]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserCollect(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserCollect]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserSchool1(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageSchoolUser]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }
        public DataSet PageUserSchool(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserSchool]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }

        public DataSet PageUserRewardList(int atid, int startid, int pagesize, out int count)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageUserReward]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            return ds;
        }

        public DataSet PageUserReward(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4),
                    new SqlParameter("@wcount", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[4].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageRewardCheck]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            wcount = int.Parse(parameters[4].Value.ToString());
            return ds;
        }

        public DataSet PageUserAdv(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4),
                    new SqlParameter("@wcount", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[4].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_PageAdvCheck]", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            wcount = int.Parse(parameters[4].Value.ToString());
            return ds;
        }
        public DataSet PageUserResume(int atid, int startid, int pagesize, out int count,out int wcount)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@atid", SqlDbType.Int,4),
                    new SqlParameter("@startIndex", SqlDbType.Int,4),
                    new SqlParameter("@endIndex", SqlDbType.Int,4),
                    new SqlParameter("@count", SqlDbType.Int,4),
                    new SqlParameter("@wcount", SqlDbType.Int,4)
};
            parameters[3].Direction = ParameterDirection.Output;
            parameters[4].Direction = ParameterDirection.Output;
            parameters[0].Value = atid;
            parameters[1].Value = startid;
            parameters[2].Value = startid + pagesize - 1;
            DataSet ds = DbHelperSQL.RunProcedure("P_PageResumeCheck", parameters, "ds");
            count = int.Parse(parameters[3].Value.ToString());
            wcount = int.Parse(parameters[4].Value.ToString());
            return ds;
        }
        public int deleteadv(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)                    
};
            parameters[0].Value = id;
            DbHelperSQL.RunProcedure("[dbo].[P_deladv]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public float getadv(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@yearpay",SqlDbType.Float,8)
                   
};
            parameters[0].Value = id;
            parameters[1].Direction = ParameterDirection.Output;
            DbHelperSQL.RunProcedure("[dbo].[P_getadv]", parameters, out rowsAffected);
            return float.Parse(parameters[1].Value.ToString());

        }
        public int updateadv(int id, float yearpay)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4) ,
                    new SqlParameter("@yearpay",SqlDbType.Float,8)
};
            parameters[0].Value = id;
            parameters[1].Value = yearpay;
            DbHelperSQL.RunProcedure("[dbo].[P_updateadv]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int deletereward(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)                    
};
            parameters[0].Value = id;
            DbHelperSQL.RunProcedure("[dbo].[P_delreward]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public float getreward(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@reward",SqlDbType.Float,8)
                   
};
            parameters[0].Value = id;
            parameters[1].Direction = ParameterDirection.Output;
            DbHelperSQL.RunProcedure("[dbo].[P_getreward]", parameters, out rowsAffected);
            return float.Parse(parameters[1].Value.ToString());

        }
        public int updatereward(int id, float reward)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4) ,
                    new SqlParameter("@reward",SqlDbType.Float,8)
};
            parameters[0].Value = id;
            parameters[1].Value = reward;
            DbHelperSQL.RunProcedure("[dbo].[P_updatereward]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int changeSubscription(int id, int sub)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@sub", SqlDbType.Int,4)
};
            parameters[0].Value = id;
            parameters[1].Value = sub;

            DbHelperSQL.RunProcedure("[dbo].[P_subscription]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int GetSubscription(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = id;
            int value = DbHelperSQL.RunProcedure("[dbo].[P_getsubscription]", parameters, out rowsAffected);
            return value;

        }
        public int changeuserstatus(int id, int status)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@status", SqlDbType.Int,4)
};
            parameters[0].Value = id;
            parameters[1].Value = status;

            DbHelperSQL.RunProcedure("[dbo].[P_chengeuserstatus]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int Getuserstatus(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = id;
            int value = DbHelperSQL.RunProcedure("[dbo].[P_getuserstatus]", parameters, out rowsAffected);
            return value;

        }
        public int changelink(int id, int status)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@showlink", SqlDbType.Int,4)
};
            parameters[0].Value = id;
            parameters[1].Value = status;

            DbHelperSQL.RunProcedure("[dbo].[P_updatelinks]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int UpdatePwd(int uid, string oldpwd, string newpwd)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@oldpwd", SqlDbType.VarChar,20),
                    new SqlParameter("@newpwd", SqlDbType.VarChar,20)
};
            parameters[0].Value = uid;
            parameters[1].Value = oldpwd;
            parameters[2].Value = newpwd;

            DbHelperSQL.RunProcedure("[dbo].[P_UpdatePwd]", parameters, out rowsAffected);
            return rowsAffected;

        }
        public int Getuserlink(int id)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
                   
};
            parameters[0].Value = id;
            int value = DbHelperSQL.RunProcedure("[dbo].[P_getislink]", parameters, out rowsAffected);
            return value;

        }
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return DbHelperSQL.GetMaxID("uid", "user_basic");
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int uid)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;

            int result = DbHelperSQL.RunProcedure("user_basic_Exists", parameters, out rowsAffected);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool Exists(string name, string i)
        {

            SqlParameter[] parameters = {
					new SqlParameter("@name", SqlDbType.VarChar,20)
};
            parameters[0].Value = name;

            object result = null;
            if (i == "1")
                result = DbHelperSQL.GetSingle("select count(*) from user_basic where [name]=@name", parameters);
            if (i == "0")
                result = DbHelperSQL.GetSingle("select count(*) from user_basic where [email]=@name", parameters);
            if (result != null)
            {
                if (result.ToString() != "0")
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
                return false;
        }
        public int getyears(SqlParameter[] parameters)
        {
            int result;
            return DbHelperSQL.RunProcedure("[dbo].[P_getuserisyear]", parameters, out result);
        }
        public void addedu(SqlParameter[] parameters)
        {
            int rowsAffected;
            DbHelperSQL.RunProcedure("[dbo].[P_AddUserEdu]", parameters, out rowsAffected);

        }
        public void addjob(SqlParameter[] parameters)
        {
            int rowsAffected;
            DbHelperSQL.RunProcedure("P_AddUserJob", parameters, out rowsAffected);

        }
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Add(lcmyjobs.Model.user_basic model, int webid, int types)
        {
            int rowsAffected;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
					new SqlParameter("@name", SqlDbType.VarChar,20),
					new SqlParameter("@pwd", SqlDbType.VarChar,20),
					new SqlParameter("@truename", SqlDbType.NVarChar,8),
					new SqlParameter("@sex", SqlDbType.Bit,1),
					new SqlParameter("@age", SqlDbType.TinyInt,1),
					new SqlParameter("@height", SqlDbType.TinyInt,1),
					new SqlParameter("@address", SqlDbType.NVarChar,20),
					new SqlParameter("@huji", SqlDbType.NVarChar,20),
					new SqlParameter("@email", SqlDbType.VarChar,30),
					new SqlParameter("@phone", SqlDbType.Char,11),
					new SqlParameter("@onlinecontact", SqlDbType.VarChar,30),
                                        new SqlParameter("@atid",SqlDbType.Int,4),
                                        new SqlParameter("@types",SqlDbType.Int,4),
                                        new SqlParameter("@uids",SqlDbType.Int,4)};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = model.name;
            parameters[2].Value = model.pwd;
            parameters[3].Value = model.truename;
            parameters[4].Value = model.sex;
            parameters[5].Value = model.age;
            parameters[6].Value = model.height;
            parameters[7].Value = model.address;
            parameters[8].Value = model.huji;
            parameters[9].Value = model.email;
            parameters[10].Value = model.phone;
            parameters[11].Value = model.onlinecontact;
            parameters[12].Value = webid;
            parameters[13].Value = types;
            if (types != 0)
            {
                parameters[14].Value = model.uid;

            }
            DbHelperSQL.RunProcedure("[dbo].[P_AddUserbasic]", parameters, out rowsAffected);
            if (rowsAffected == 1)
                if (types != 0)
                    return rowsAffected;
                else
                    return (int)parameters[0].Value;
            else
                return 0;
        }

        /// <summary>
        ///  更新一条数据
        /// </summary>
        public bool Update(lcmyjobs.Model.user_basic model)
        {
            int rowsAffected = 0;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
					new SqlParameter("@name", SqlDbType.VarChar,10),
					new SqlParameter("@pwd", SqlDbType.VarChar,20),
					new SqlParameter("@truename", SqlDbType.NVarChar,8),
					new SqlParameter("@sex", SqlDbType.Bit,1),
					new SqlParameter("@age", SqlDbType.TinyInt,1),
					new SqlParameter("@height", SqlDbType.TinyInt,1),
					new SqlParameter("@address", SqlDbType.NVarChar,20),
					new SqlParameter("@huji", SqlDbType.NVarChar,20),
					new SqlParameter("@email", SqlDbType.VarChar,30),
					new SqlParameter("@phone", SqlDbType.Char,11),
					new SqlParameter("@onlinecontact", SqlDbType.VarChar,30),
					new SqlParameter("@edus_id", SqlDbType.Int,4),
					new SqlParameter("@school", SqlDbType.VarChar,50),
					new SqlParameter("@eduyear", SqlDbType.Char,4),
					new SqlParameter("@utype", SqlDbType.TinyInt,1),
					new SqlParameter("@workexp_id", SqlDbType.Int,4),
					new SqlParameter("@jsid", SqlDbType.Int,4),
					new SqlParameter("@jobtime", SqlDbType.NVarChar,20),
					new SqlParameter("@pay", SqlDbType.Float,8),
					new SqlParameter("@status", SqlDbType.TinyInt,1),
					new SqlParameter("@issubscription", SqlDbType.Bit,1),
					new SqlParameter("@isshowlink", SqlDbType.Bit,1),
					new SqlParameter("@loginnum", SqlDbType.Int,4),
					new SqlParameter("@todayloginnum", SqlDbType.Int,4),
					new SqlParameter("@logintime", SqlDbType.DateTime),
					new SqlParameter("@wantedtime", SqlDbType.DateTime),
					new SqlParameter("@wantedstatus", SqlDbType.Bit,1)};
            parameters[0].Value = model.uid;
            parameters[1].Value = model.name;
            parameters[2].Value = model.pwd;
            parameters[3].Value = model.truename;
            parameters[4].Value = model.sex;
            parameters[5].Value = model.age;
            parameters[6].Value = model.height;
            parameters[7].Value = model.address;
            parameters[8].Value = model.huji;
            parameters[9].Value = model.email;
            parameters[10].Value = model.phone;
            parameters[11].Value = model.onlinecontact;
            parameters[12].Value = model.edus_id;
            parameters[13].Value = model.school;
            parameters[14].Value = model.eduyear;
            parameters[15].Value = model.utype;
            parameters[16].Value = model.workexp_id;
            parameters[17].Value = model.jsid;
            parameters[18].Value = model.jobtime;
            parameters[19].Value = model.pay;
            parameters[20].Value = model.status;
            parameters[21].Value = model.issubscription;
            parameters[22].Value = model.isshowlink;
            parameters[23].Value = model.loginnum;
            parameters[24].Value = model.todayloginnum;
            parameters[25].Value = model.logintime;
            parameters[26].Value = model.wantedtime;
            parameters[27].Value = model.wantedstatus;

            DbHelperSQL.RunProcedure("user_basic_Update", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int uid)
        {
            int rowsAffected = 0;
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;

            DbHelperSQL.RunProcedure("P_userdelete", parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 批量删除数据
        /// </summary>
        public bool DeleteList(string uidlist)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from user_basic ");
            strSql.Append(" where uid in (" + uidlist + ")  ");
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public DataSet GetUserBasic(int uid)//P_getuseredu
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_getuserbasic]", parameters, "ds");
            return ds;
        }
        public DataSet GetUserEdu(int uid)//P_getuseredu
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            DataSet ds = DbHelperSQL.RunProcedure("P_getuseredu", parameters, "ds");
            return ds;
        }
        public DataSet GetUserJob(int uid)//P_getuseredu
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;
            DataSet ds = DbHelperSQL.RunProcedure("P_getuserjob", parameters, "ds");
            return ds;
        }
        public DataSet GetUserResume(int uid, int eid, int isself)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4),
                    new SqlParameter("@enterprise_bid", SqlDbType.Int,4),
                    new SqlParameter("@isself",SqlDbType.Bit,1)
};
            parameters[0].Value = uid;
            parameters[1].Value = eid;
            parameters[2].Value = isself;
            DataSet ds = DbHelperSQL.RunProcedure("[dbo].[P_getresume]", parameters, "ds");
            return ds;

        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lcmyjobs.Model.user_basic GetModel(int uid)
        {
            SqlParameter[] parameters = {
					new SqlParameter("@uid", SqlDbType.Int,4)
};
            parameters[0].Value = uid;

            lcmyjobs.Model.user_basic model = new lcmyjobs.Model.user_basic();
            DataSet ds = DbHelperSQL.RunProcedure("user_basic_GetModel", parameters, "ds");
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["uid"] != null && ds.Tables[0].Rows[0]["uid"].ToString() != "")
                {
                    model.uid = int.Parse(ds.Tables[0].Rows[0]["uid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["name"] != null && ds.Tables[0].Rows[0]["name"].ToString() != "")
                {
                    model.name = ds.Tables[0].Rows[0]["name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pwd"] != null && ds.Tables[0].Rows[0]["pwd"].ToString() != "")
                {
                    model.pwd = ds.Tables[0].Rows[0]["pwd"].ToString();
                }
                if (ds.Tables[0].Rows[0]["truename"] != null && ds.Tables[0].Rows[0]["truename"].ToString() != "")
                {
                    model.truename = ds.Tables[0].Rows[0]["truename"].ToString();
                }
                if (ds.Tables[0].Rows[0]["sex"] != null && ds.Tables[0].Rows[0]["sex"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["sex"].ToString() == "1") || (ds.Tables[0].Rows[0]["sex"].ToString().ToLower() == "true"))
                    {
                        model.sex = true;
                    }
                    else
                    {
                        model.sex = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["age"] != null && ds.Tables[0].Rows[0]["age"].ToString() != "")
                {
                    model.age = int.Parse(ds.Tables[0].Rows[0]["age"].ToString());
                }
                if (ds.Tables[0].Rows[0]["height"] != null && ds.Tables[0].Rows[0]["height"].ToString() != "")
                {
                    model.height = int.Parse(ds.Tables[0].Rows[0]["height"].ToString());
                }
                if (ds.Tables[0].Rows[0]["address"] != null && ds.Tables[0].Rows[0]["address"].ToString() != "")
                {
                    model.address = ds.Tables[0].Rows[0]["address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["huji"] != null && ds.Tables[0].Rows[0]["huji"].ToString() != "")
                {
                    model.huji = ds.Tables[0].Rows[0]["huji"].ToString();
                }
                if (ds.Tables[0].Rows[0]["email"] != null && ds.Tables[0].Rows[0]["email"].ToString() != "")
                {
                    model.email = ds.Tables[0].Rows[0]["email"].ToString();
                }
                if (ds.Tables[0].Rows[0]["phone"] != null && ds.Tables[0].Rows[0]["phone"].ToString() != "")
                {
                    model.phone = ds.Tables[0].Rows[0]["phone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["onlinecontact"] != null && ds.Tables[0].Rows[0]["onlinecontact"].ToString() != "")
                {
                    model.onlinecontact = ds.Tables[0].Rows[0]["onlinecontact"].ToString();
                }
                if (ds.Tables[0].Rows[0]["edus_id"] != null && ds.Tables[0].Rows[0]["edus_id"].ToString() != "")
                {
                    model.edus_id = int.Parse(ds.Tables[0].Rows[0]["edus_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["school"] != null && ds.Tables[0].Rows[0]["school"].ToString() != "")
                {
                    model.school = ds.Tables[0].Rows[0]["school"].ToString();
                }
                if (ds.Tables[0].Rows[0]["eduyear"] != null && ds.Tables[0].Rows[0]["eduyear"].ToString() != "")
                {
                    model.eduyear = ds.Tables[0].Rows[0]["eduyear"].ToString();
                }
                if (ds.Tables[0].Rows[0]["utype"] != null && ds.Tables[0].Rows[0]["utype"].ToString() != "")
                {
                    model.utype = int.Parse(ds.Tables[0].Rows[0]["utype"].ToString());
                }
                if (ds.Tables[0].Rows[0]["workexp_id"] != null && ds.Tables[0].Rows[0]["workexp_id"].ToString() != "")
                {
                    model.workexp_id = int.Parse(ds.Tables[0].Rows[0]["workexp_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["jsid"] != null && ds.Tables[0].Rows[0]["jsid"].ToString() != "")
                {
                    model.jsid = int.Parse(ds.Tables[0].Rows[0]["jsid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["jobtime"] != null && ds.Tables[0].Rows[0]["jobtime"].ToString() != "")
                {
                    model.jobtime = ds.Tables[0].Rows[0]["jobtime"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pay"] != null && ds.Tables[0].Rows[0]["pay"].ToString() != "")
                {
                    model.pay = decimal.Parse(ds.Tables[0].Rows[0]["pay"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["issubscription"] != null && ds.Tables[0].Rows[0]["issubscription"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["issubscription"].ToString() == "1") || (ds.Tables[0].Rows[0]["issubscription"].ToString().ToLower() == "true"))
                    {
                        model.issubscription = true;
                    }
                    else
                    {
                        model.issubscription = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["isshowlink"] != null && ds.Tables[0].Rows[0]["isshowlink"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["isshowlink"].ToString() == "1") || (ds.Tables[0].Rows[0]["isshowlink"].ToString().ToLower() == "true"))
                    {
                        model.isshowlink = true;
                    }
                    else
                    {
                        model.isshowlink = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["loginnum"] != null && ds.Tables[0].Rows[0]["loginnum"].ToString() != "")
                {
                    model.loginnum = int.Parse(ds.Tables[0].Rows[0]["loginnum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["todayloginnum"] != null && ds.Tables[0].Rows[0]["todayloginnum"].ToString() != "")
                {
                    model.todayloginnum = int.Parse(ds.Tables[0].Rows[0]["todayloginnum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["logintime"] != null && ds.Tables[0].Rows[0]["logintime"].ToString() != "")
                {
                    model.logintime = DateTime.Parse(ds.Tables[0].Rows[0]["logintime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["wantedtime"] != null && ds.Tables[0].Rows[0]["wantedtime"].ToString() != "")
                {
                    model.wantedtime = DateTime.Parse(ds.Tables[0].Rows[0]["wantedtime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["wantedstatus"] != null && ds.Tables[0].Rows[0]["wantedstatus"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["wantedstatus"].ToString() == "1") || (ds.Tables[0].Rows[0]["wantedstatus"].ToString().ToLower() == "true"))
                    {
                        model.wantedstatus = true;
                    }
                    else
                    {
                        model.wantedstatus = false;
                    }
                }
                return model;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select uid,name,pwd,truename,sex,age,height,address,huji,email,phone,onlinecontact,edus_id,school,eduyear,utype,workexp_id,jsid,jobtime,pay,status,issubscription,isshowlink,loginnum,todayloginnum,logintime,wantedtime,wantedstatus ");
            strSql.Append(" FROM user_basic ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ");
            if (Top > 0)
            {
                strSql.Append(" top " + Top.ToString());
            }
            strSql.Append(" uid,name,pwd,truename,sex,age,height,address,huji,email,phone,onlinecontact,edus_id,school,eduyear,utype,workexp_id,jsid,jobtime,pay,status,issubscription,isshowlink,loginnum,todayloginnum,logintime,wantedtime,wantedstatus ");
            strSql.Append(" FROM user_basic ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            strSql.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(strSql.ToString());
        }

        /*
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@tblName", SqlDbType.VarChar, 255),
                    new SqlParameter("@fldName", SqlDbType.VarChar, 255),
                    new SqlParameter("@PageSize", SqlDbType.Int),
                    new SqlParameter("@PageIndex", SqlDbType.Int),
                    new SqlParameter("@IsReCount", SqlDbType.Bit),
                    new SqlParameter("@OrderType", SqlDbType.Bit),
                    new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
                    };
            parameters[0].Value = "user_basic";
            parameters[1].Value = "uid";
            parameters[2].Value = PageSize;
            parameters[3].Value = PageIndex;
            parameters[4].Value = 0;
            parameters[5].Value = 0;
            parameters[6].Value = strWhere;	
            return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
        }*/

        #endregion  Method
    }
}

